<div class="main-content">
    <div class="section__content section__content--p20">
        <div class="container-fluid">
            <div class="row m-b-30">
                <div class="col-lg-12">
                    <div class="overview-wrap">
                        <h2 class="title-1">基本设置</h2>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-lg-12">
                    <div class="card">
                        <div class="card-header">
                            <strong>基本设置</strong>
                        </div>
                        <div class="card-body">
                            <form class="form-horizontal" role="form" name="form" id="form" method="post"
                                  data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                                  data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                                  data-bv-feedbackicons-validating="glyphicon glyphicon-refresh"
                                  action="index.php?r=admin/config/basicedit" enctype="multipart/form-data">
                                <input type="hidden" name="module" value="basic"/>
                                <input type="hidden" name="YII_CSRF_TOKEN" value="<?php echo Yii::app()->request->csrfToken; ?>"/>
                                <input type="hidden" name="form_rd" data-bv-notempty="true" value="1">

                                <div class="form-group">
                                    <label  class="control-label mb-1">网站名称</label>
                                    <input type="text" class="form-control" name="webname" placeholder="网站名称"
                                           value="<?php echo $basicconfig['webname']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站名称是必须的！"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站LOGO</label>
                                    <input type="text" class="form-control" placeholder="网站LOGO" name="weblogo"
                                           value="<?php echo $basicconfig['weblogo']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站LOGO是必须的！"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">LOGO</label>
                                    <input type="file" class="block form-control" name="image" id="image" onchange="enableForm()"/>
                                </div>

                                <?php
                                if (!is_null($basicconfig['weblogo']['content'])) {
                                    ?>
                                    <div class="form-group">
                                        <label class=" form-control-label">预览</label>
                                        <div class="form-control">
                                            <img  style="height: 50px;" id="logo_view"
                                                  src="<?php echo $basicconfig['weblogo']['content']; ?>">
                                        </div>
                                    </div>
                                    <?php
                                }
                                ?>
                                <div class="form-group">
                                    <label class=" form-control-label">网站网址</label>
                                    <input type="text" class="form-control" placeholder="网站网址" name="weburl"
                                           value="<?php echo $basicconfig['weburl']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站网址是必须的！" data-bv-uri="true" data-bv-uri-message="网站网址格式不正确"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站关键字</label>
                                    <input type="text" class="form-control" placeholder="网站关键字" name="webkeyword"
                                           value="<?php echo $basicconfig['webkeyword']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站关键字是必须的！"/>
                                    <small>多个关键词请用竖线|隔开，建议3到4个关键词。</small>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站描述</label>
                                    <textarea MAXLENGTH="100" class="form-control" rows="3"
                                              name="webdesc" data-bv-notempty="true"
                                              data-bv-notempty-message="网站描述是必须的！"><?php echo $basicconfig['webdesc']['content']; ?></textarea>
                                    <small>100字以内</small>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">ICP备案号</label>
                                    <input type="text" class=" form-control " name="icp" data-bv-notempty="true"
                                           data-bv-notempty-message="ICP备案号是必须的！"
                                           value="<?php echo $basicconfig['icp']['content']; ?>"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站联系电话</label>
                                    <input type="text" class="form-control " name="webtel"
                                           value="<?php echo $basicconfig['webtel']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站联系电话是必须的！"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站联系手机</label>
                                    <input type="text" class=" form-control " name="webphone"
                                           value="<?php echo $basicconfig['webphone']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站联系手机是必须的！"/>
                                </div>

                                <div class="form-group">
                                    <label class=" form-control-label">网站联系Email</label>
                                    <input type="text" class=" form-control " name="webemail"
                                           value="<?php echo $basicconfig['webemail']['content']; ?>" data-bv-notempty="true"
                                           data-bv-notempty-message="网站联系Email是必须的！" data-bv-emailAddress="true" data-bv-emailAddress-message="网站联系Email格式不正确"/>
                                </div>

                                <div class="form-group">
                                    <button  type="submit" name="submit" id="submit" class="btn btn-primary btn-lg btn-block">保存</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(document).ready(function () {
        initPage();
    });
    function initPage() {
        $('#form').bootstrapValidator();
        $('#form').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (formData, jqForm, options) {
                return $('#form').data('bootstrapValidator').isValid();
            },
            success: function (res) {
                if (message(res)) {
                    $("#logo_view").attr("src", res.data.weblogo.content);
                }
            }
        });
    }
    function enableForm() {
        $("input[name=submit]").removeProp("disabled");
    }
</script>